package net.starwifi.duobao.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2015/11/23.
 */
public class DBTimesHelper {


    public static String getSH(){
        String lastestpri="";
        try {
            Map<String,Object> p=new HashMap<String, Object>();
            p.put("key", "60b42d5e467e4b3e9ed5258e285a7fd0");
            String json=HttpUtils.get("http://apis.haoservice.com/lifeservice/stock/hq", p);
            System.out.println(json);
            JSONObject jsonStr= JSON.parseObject(json);
            if(jsonStr!=null){
                if(jsonStr.getJSONObject("result")!=null){
                    lastestpri=jsonStr.getJSONObject("result").getString("lastestpri");
                    lastestpri=lastestpri.replace(".","");
                }
            }
        }catch (Exception e){
            e.printStackTrace();
            lastestpri="1000000";
        }
        return lastestpri;
    }




    public static String getSZ(){
        String lastestpri="";
        try {
            Map<String,Object> p=new HashMap<String, Object>();
            p.put("key", "60b42d5e467e4b3e9ed5258e285a7fd0");
            p.put("gid", "60b42d5e467e4b3e9ed5258e285a7fd0");
            String json=HttpUtils.get("http://apis.haoservice.com/lifeservice/stock/hs", p);
            System.out.println(json);
            JSONObject jsonStr= JSON.parseObject(json);
            if(jsonStr!=null){
                if(jsonStr.getJSONObject("result")!=null){
                    lastestpri=jsonStr.getJSONObject("result").getString("lastestpri");
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return lastestpri;
    }
    public static void main(String args[]) {

        System.out.println( getSH());
        System.out.println( getSZ());
    }


}
